import { Component, OnInit, ViewChild } from '@angular/core';
import { My2Component } from '../my2/my2.component';

@Component({
    selector: 'my1',
    templateUrl: './my1.component.html',
    styleUrls: ['./my1.component.scss']
})


export class My1Component implements OnInit {
    @ViewChild('my2') my2:My2Component | undefined;
    constructor() {
        console.log('第一个触发')
        let self=this
        this.getFn =this.getFn.bind(self)
     }
     getFn (number:number) {
         console.log(number,this)
        this.amount1 = number
     }
    name:string = 'hello world'
    amount1:number = 10
    time = new Date().getTime()
    html = "<span>123</span>"
    type = 0
    style = {
     color:'blue'   
    }
    items = [122,222,223]
    jobs = [
        {
            name: '啊啊',
            age:12,
            sex:'1'
        },
        {
            name: '啊啊',
            age:12,
            sex:'0'
        }
    ]
    showClick (number:number) {
        this.amount1 = this.amount1 + number
        this.type++
    }
    ngOnInit(): void {
        console.log('组件内容开始初始化')
     }
    ngOnDestroy(): void {
        //Called once, before the instance is destroyed.
        //Add 'implements OnDestroy' to the class.
        
    }
    ngOnChanges(): void {
        //Called before any other lifecycle hook. Use it to inject dependencies, but avoid any serious work here.
        //Add '${implements OnChanges}' to the class.
        
    }
    ngAfterContentInit(): void {
        //Called after ngOnInit when the component's or directive's content has been initialized.
        //Add 'implements AfterContentInit' to the class.
        console.log('组件数据开始初始化')
    }
    ngAfterViewInit(): void {
        //Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
        //Add 'implements AfterViewInit' to the class.
        console.log('组件ui界面开始初始化',this.my2)
        
    }
    ngAfterViewChecked(): void {
        //Called after every check of the component's view. Applies to components only.
        //Add 'implements AfterViewChecked' to the class.
        console.log('组件ui界面随着数据改变而变化')
    }
}